package cn.Observer3;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jt on 2018/3/22.
 */
public class Bell implements Observable {

    private List<Observer> observers = new ArrayList<>() ;

    @Override
    public void addObserver(Observer observer) {
        this.observers.add(observer) ;
    }

    @Override
    public void deleteObserver(Observer observer) {
        this.observers.remove(observer) ;
    }

    @Override
    public void notifyObserver(String msg) {
        for(Observer observer : observers){
            observer.uodate(msg);
        }
    }

    public void classIsOver(){
        System.out.println("下课铃响了");
        this.notifyObserver("下课");
    }
    public void classBegin() {
        System.out.println("上课铃响了");
        this.notifyObserver("上课");
    }

}
